<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}\js\jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>


<script type="text/javascript">
$(function(){
	
//查询所有未被选择的课题
$('#dg').datagrid({    
    url:'course', 
    //列表显示
    columns:[[    
        {field:'co',checkbox:'true',title:'Code',align:'center'},    
        {field:'cid',title:'课题标号',width:100,align:'center'},    
        {field:'cname',title:'课题名称',width:100,align:'center'},    
        {field:'cstate',title:'选择状态',width:100,align:'center'},
        {field:'tid',title:'教师编号',width:100,align:'center'},
        {field:'tname',title:'教师名字',width:100,align:'center'},    
        {field:'tdepart',title:'院系',width:100,align:'center'},    
        {field:'tprofe',title:'职称',width:100,align:'center'},
        {field:'ttel',title:'教师电话',width:100,align:'center'}        
    ]],
    pagination:true,
    pagePosition:'bottom',
    rownumbers:true,
    pageNumber:1,
    pageSize:2,
    pageList:[5,10,15],
//工具栏 
	toolbar: [{
		iconCls: 'icon-edit',
		text:"确定选择",
		handler: function(){
			var cou=$('#dg').datagrid('getChecked');			
			if(cou.length==1){		
				var cid=cou[0].cid;
				var cstate=cou[0].cstate;			
			$.ajax({
				type : "post",
				url : "selectcourse",
				data : {
					'cid' : cid,
					'cstate':cstate,
				},
				dataType : "text",
				success : function(data){				
					if(data==1){						
						$.messager.alert('提示','选择成功');						
					}else{
						$.messager.alert('提示','选择失败或者已选择课题');	
					}					
					var cou=$('#dg').datagrid('reload');
					var cou=$('#dg1').datagrid('reload');
				}
			})
			}else{
				$.messager.alert('提示','请选择一行');
			}			
			}		
	},'-',{
		iconCls: 'icon-cut',
		text:"修改课题",
		handler: function(){
			
				$.ajax({
					type : "post",
					url : "updatecou",
					data : {	},
					dataType : "text",
					success : function(data){
						if(data==1){						
							$.messager.alert('提示','选择成功');						
						}else{
							$.messager.alert('提示','选择失败或者已选择课题');	
						}					
						var cou=$('#dg').datagrid('reload');
						var cou=$('#dg1').datagrid('reload');

					}
					})			
		
			
			
			
		}
	}]	
}); 

//显示已经选择的课题
$('#dg1').datagrid({    
    url:'course2', 
    title:'已选择的课题信息',
    columns:[[    
			{field:'co',checkbox:'true',title:'Code',align:'center'},    
			{field:'cid',title:'课题标号',width:100,align:'center'},    
			{field:'cname',title:'课题名称',width:100,align:'center'},    
			{field:'cstate',title:'选择状态',width:100,align:'center'},
			{field:'tid',title:'教师编号',width:100,align:'center'},
			{field:'tname',title:'教师名字',width:100,align:'center'},    
			{field:'tdepart',title:'院系',width:100,align:'center'},    
			{field:'tprofe',title:'职称',width:100,align:'center'},
			{field:'ttel',title:'教师电话',width:100,align:'center'},		
    ]],  
});  

})
</script>
<body>


<table id="dg"></table> 
 

<table id="dg1"></table>

</body>
</html>